package com.efounder.util;

import com.pansoft.espmodel.EFWebNoticationObject;

import java.lang.reflect.Method;

public class WebViewUtil{
	
	
	public static String openEspUrl(String url){
		String result = "";
		String method = url.substring(url.lastIndexOf("/")+1,url.indexOf("("));
	    String[] params = url.split(",");
	
	    result = reFlect(method,params);
		return result;
	}
	public static String  openEspMap(EFWebNoticationObject efWebNoticationObject){
		String result = "";
		String method = efWebNoticationObject.getType();
		String[] param = efWebNoticationObject.getParam();
		result = reFlect(method, param);
		return result;
	}
	
	
	private static String reFlect(String method,String[] params){
		String result="";
		Class[]  parameterTypes = new  Class[params.length];
	    for(int i=0;i<params.length;i++){
	    	parameterTypes[i] = String.class;
	    }
		try { 
        	Method m = WebViewUtil.class.getDeclaredMethod(method, parameterTypes);
//        	result = m.invoke(method,params).toString();
			
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (InvocationTargetException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		return result;
	}
	private static String carmera(String a ,String b){
		String result = "";
		System.out.println("a===="+a+".....b="+b);
		return result;
	}
	private static String Date(String date){
		return date;
	}
}